<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>بازی ماشین‌سواری فانتزی و واژگان</title>
    
    <link rel="preconnect" href="https://my.uupload.ir">
    <link rel="dns-prefetch" href="https://my.uupload.ir">
    <link rel="preload" as="image" href="https://my.uupload.ir/dl/dxvWVZXo">
    <link rel="preload" as="image" href="https://my.uupload.ir/dl/5L085bXd">

    <style>
        :root {
            --primary: #FF5252;
            --secondary: #448AFF;
            --success: #69F0AE;
            --warning: #FFD740;
            --dark: #2c3e50;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            user-select: none;
            font-family: Tahoma, Arial, Helvetica, sans-serif;
        }

        body {
            background-color: #2E7D32; 
            overflow: hidden;
            touch-action: none;
        }

        #gameCanvas {
            display: block;
            margin: 0 auto;
            box-shadow: 0 0 30px rgba(0,0,0,0.9);
        }

        .hud {
            position: absolute;
            top: 10px;
            width: 100%;
            display: flex;
            justify-content: space-between;
            padding: 0 20px;
            pointer-events: none;
            z-index: 10;
        }

        .hud-box {
            background: rgba(255, 255, 255, 0.95);
            padding: 10px 15px;
            border-radius: 15px;
            border: 2px solid #ccc;
            box-shadow: 0 5px 15px rgba(0,0,0,0.4);
            font-weight: bold;
            color: var(--dark);
            font-size: 14px;
            pointer-events: auto;
        }

        .level-banner {
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(145deg, #FFD740, #FF8F00);
            padding: 8px 25px;
            border-radius: 20px;
            font-size: 20px;
            font-weight: 900;
            color: #fff;
            border: 3px solid #fff;
            box-shadow: 0 5px 15px rgba(0,0,0,0.5);
            z-index: 20;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            transition: transform 0.3s;
        }

        .mute-btn {
            background: #fff;
            border: 2px solid #ccc;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            font-size: 20px;
            cursor: pointer;
            box-shadow: 0 4px 6px rgba(0,0,0,0.3);
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 10px;
        }

        .controls {
            position: absolute;
            bottom: 20px;
            width: 100%;
            display: flex;
            justify-content: center; /* قرارگیری در مرکز */
            gap: 25px; /* فاصله بین دکمه‌ها */
            align-items: flex-end;
            padding: 0 20px;
            z-index: 10;
        }

        .btn {
            background: linear-gradient(145deg, #448AFF, #1976D2);
            color: white;
            border: none;
            width: 70px;
            height: 70px;
            border-radius: 50%;
            font-size: 24px;
            font-weight: 900;
            box-shadow: 0 8px 0 #0D47A1, 0 15px 20px rgba(0,0,0,0.5);
            cursor: pointer;
            transition: transform 0.1s, box-shadow 0.1s;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .btn:active {
            transform: translateY(8px);
            box-shadow: 0 0px 0 #0D47A1, 0 5px 10px rgba(0,0,0,0.5);
        }

        .btn-shoot {
            background: linear-gradient(145deg, #FF5252, #D50000);
            box-shadow: 0 8px 0 #B71C1C, 0 15px 20px rgba(0,0,0,0.5);
            width: 80px;
            height: 80px;
            font-size: 28px;
        }
        
        .btn-shoot:active {
            transform: translateY(8px);
            box-shadow: 0 0px 0 #B71C1C, 0 5px 10px rgba(0,0,0,0.5);
        }

        #questionModal, #startModal, #gameOverModal, #messageModal, #guideModal, #level10Modal {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.85);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 100;
        }

        #guideModal { z-index: 150; }
        #level10Modal { z-index: 180; }

        #countdownModal {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.7);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 200;
            color: #FFD740;
            text-align: center;
            overflow: hidden;
        }

        #countdownText {
            font-size: 120px;
            font-weight: 900;
            text-shadow: 0 10px 30px rgba(0,0,0,0.8);
            display: block;
        }
        
        #continueText {
            font-size: 30px;
            color: white;
            margin-top: -20px;
            text-shadow: 0 5px 10px rgba(0,0,0,0.8);
        }

        .encouragement {
            font-size: 40px;
            color: #69F0AE;
            text-shadow: 0 5px 15px rgba(0,0,0,0.9);
            margin-bottom: 20px;
            font-weight: 900;
            animation: popIn 0.5s ease-out;
            padding: 0 10px;
        }

        @keyframes popIn {
            0% { transform: scale(0.5); opacity: 0; }
            100% { transform: scale(1); opacity: 1; }
        }

        .modal-content {
            background: #fff;
            padding: 25px;
            border-radius: 20px;
            text-align: center;
            max-width: 95%;
            width: 450px;
            border: 4px solid var(--warning);
            box-shadow: 0 10px 40px rgba(0,0,0,0.7);
            max-height: 95vh;
            overflow-y: auto;
        }

        .start-screen-content {
            padding: 20px;
            width: 400px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .modal-content h2 { margin-bottom: 15px; color: var(--dark); font-size: 22px;}
        .modal-content input {
            width: 100%;
            padding: 15px;
            font-size: 18px;
            border: 2px solid #ccc;
            border-radius: 10px;
            margin-bottom: 20px;
            text-align: center;
            outline: none;
        }
        
        .options-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 10px;
            margin-top: 15px;
        }

        .option-btn {
            background: var(--secondary);
            color: white;
            border: none;
            padding: 14px;
            font-size: 15px;
            font-weight: bold;
            border-radius: 10px;
            cursor: pointer;
            box-shadow: 0 4px 0 #1976D2;
            transition: background 0.2s, transform 0.1s;
            white-space: normal;
            line-height: 1.5;
        }

        .option-btn:active { transform: translateY(4px); box-shadow: none; }
        
        .start-btn {
            background: linear-gradient(145deg, #69F0AE, #00C853);
            color: var(--dark);
            border: none;
            padding: 15px 35px;
            font-size: 18px;
            font-weight: bold;
            border-radius: 15px;
            cursor: pointer;
            box-shadow: 0 6px 0 #009624;
            transition: transform 0.1s, box-shadow 0.1s;
            margin-top: 10px;
            width: 100%;
        }
        
        .start-btn:active {
            transform: translateY(6px);
            box-shadow: 0 0px 0 #009624;
        }

        .continue-btn {
            background: linear-gradient(145deg, #FF9800, #F57C00);
            box-shadow: 0 6px 0 #E65100;
            color: white;
            margin-bottom: 10px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            text-align: right;
            background: #f8f9fa;
            padding: 15px;
            border-radius: 10px;
            border: 1px solid #ddd;
            margin-bottom: 15px;
        }
        
        .motivation {
            font-size: 16px;
            color: #1976D2;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .boss-hp-bar {
            position: absolute;
            top: 60px;
            left: 50%;
            transform: translateX(-50%);
            width: 80%;
            height: 20px;
            background: #333;
            border: 2px solid #FFF;
            border-radius: 10px;
            display: none;
            z-index: 10;
        }
        .boss-hp-fill {
            width: 100%;
            height: 100%;
            background: #FF1744;
            border-radius: 8px;
            transition: width 0.2s;
        }

        @keyframes pulse-glow {
            0% { box-shadow: 0 0 5px #BBDEFB, 0 0 10px #BBDEFB; transform: scale(1); }
            50% { box-shadow: 0 0 15px #448AFF, 0 0 25px #448AFF; transform: scale(1.02); }
            100% { box-shadow: 0 0 5px #BBDEFB, 0 0 10px #BBDEFB; transform: scale(1); }
        }

        .promo-box {
            animation: pulse-glow 2.5s infinite ease-in-out;
            cursor: pointer;
            background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
            color: #0D47A1;
            padding: 15px;
            border-radius: 12px;
            font-weight: 900;
            margin-bottom: 20px;
            border: 2px dashed #1976D2;
            transition: all 0.3s;
            text-align: center;
        }

        .promo-box:hover {
            transform: scale(1.03);
            background: #D0E9FF;
        }

        .guide-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
            padding: 10px 0;
            margin-bottom: 15px;
        }

        .guide-item {
            background: linear-gradient(145deg, #ffffff, #f0f0f0);
            border-radius: 15px;
            padding: 12px 15px;
            box-shadow: 5px 5px 10px #d9d9d9, -5px -5px 10px #ffffff;
            border: 1px solid #eee;
            display: flex;
            align-items: center;
            gap: 12px;
            text-align: right;
            font-size: 14px;
            line-height: 1.6;
            color: #333;
        }
        
        .guide-item .icon {
            font-size: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 40px;
        }

        @media print {
            body * { visibility: hidden; }
            #gameOverModal, #gameOverModal * { visibility: visible; }
            #gameOverModal { position: absolute; left: 0; top: 0; background: white !important; display: block; }
            .modal-content { border: none; box-shadow: none; width: 100%; margin: 0 auto; }
            .no-print { display: none !important; }
        }
    </style>
</head>
<body>

    <div class="hud" id="hud" style="display:none;">
        <div style="display: flex; flex-direction: column;">
            <button id="muteBtn" class="mute-btn" onclick="toggleMute()">🔊</button>
            <div class="hud-box">
                ⏱ زمان: <span id="timeDisplay">0</span>s<br>
                🛣 مسافت: <span id="distDisplay">0.0</span> km<br>
                ⚡ سرعت: <span id="speedDisplay">100</span>%
            </div>
        </div>
        <div id="levelDisplay" class="level-banner">سطح ۱</div>
        <div class="hud-box" style="text-align: left;">
            👤 <span id="nameDisplay">بازیکن</span><br>
            ⭐ امتیاز: <span id="scoreDisplay">0</span><br>
            ❤️ جان: <span id="livesDisplay">❤️❤️❤️❤️❤️</span><br>
            🔫 تیر: <span id="ammoDisplay">5</span><br>
            ✅ صحیح: <span id="correctDisplay">0</span>
        </div>
    </div>

    <div class="boss-hp-bar" id="bossHpBar"><div class="boss-hp-fill" id="bossHpFill"></div></div>

    <canvas id="gameCanvas"></canvas>

    <div class="controls" id="controls" style="display:none;">
        <!-- در دایرکشن راست به چپ، المان اول سمت راست قرار می‌گیرد -->
        <button class="btn" id="btnRight">▶</button>
        <button class="btn btn-shoot" id="btnShoot">💥</button>
        <button class="btn" id="btnLeft">◀</button>
    </div>

    <!-- مودال شروع -->
    <div id="startModal" style="display:flex;">
        <div class="modal-content start-screen-content">
            <img src="https://s15.uupload.ir/files/notebooklm/IMG_20240410_190931_546.png" alt="Logo" style="width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin-bottom: 15px; border: 4px solid var(--primary); box-shadow: 0 4px 10px rgba(0,0,0,0.3);">
            <h1 style="color: var(--primary); font-size: 26px; margin-bottom: 10px; text-shadow: 1px 1px 2px rgba(0,0,0,0.2);">🚗 نبرد واژگان در جاده</h1>
            <p style="font-size: 14px; margin-bottom: 25px; color: #444; font-weight: bold;">به بازی آموزشی ما خوش آمدی! ماشینت رو هدایت کن، کلمات رو یاد بگیر و غول‌ها رو شکست بده.</p>
            
            <div class="promo-box" onclick="window.open('https://eitaa.com/joinchat/2951021951C718cb20119', '_blank')">
                🚀 برای کشف بازی‌های هیجان‌انگیزتر و ترفندهای جادویی هوش مصنوعی، اینجا کلیک کن!
            </div>
            
            <input type="text" id="playerNameInput" placeholder="نام خودت رو اینجا بنویس...">
            <button class="start-btn" onclick="showGuide()">شروع بازی</button>
        </div>
    </div>

    <!-- مدال راهنما -->
    <div id="guideModal">
        <div class="modal-content" style="border-color: #4CAF50;">
            <h2 style="color: #4CAF50; margin-bottom: 20px;">📚 راهنمای بازی</h2>
            <div class="guide-list">
                <div class="guide-item">
                    <div class="icon">🕹️</div>
                    <div><b>حرکت:</b> با دکمه‌های جهت کیبورد یا دکمه‌های ◀ و ▶ روی صفحه، ماشین را به چپ و راست ببر.</div>
                </div>
                <div class="guide-item">
                    <div class="icon">💥</div>
                    <div><b>شلیک:</b> با دکمه وسط (💥) یا کلید <b>Space</b> کیبورد به ماشین‌های دشمن شلیک کن.</div>
                </div>
                <div class="guide-item">
                    <div class="icon">💖</div>
                    <div><strong style="color:#FF1493;">قلب (تعمیر):</strong> گرفتن آن، یک جان اضافه می‌دهد.</div>
                </div>
                <div class="guide-item">
                    <div class="icon">💠</div>
                    <div><strong style="color:#00B0FF;">خشاب:</strong> گرفتن آن، ۵ تیر به اسلحه‌ات اضافه می‌کند.</div>
                </div>
                <div class="guide-item">
                    <div class="icon">⚡</div>
                    <div><strong style="color:#D4C000;">توربو:</strong> به سرعتت اضافه می‌کند و سریع‌تر پیش می‌روی.</div>
                </div>
                <div class="guide-item">
                    <div class="icon">🛡️</div>
                    <div><strong style="color:#FFC107;">محافظ:</strong> برای چند ثانیه در برابر تصادفات مقاوم می‌شوی.</div>
                </div>
                <div class="guide-item" style="background: #fff3e0; border-color: #ffb74d;">
                    <div class="icon">⚠️</div>
                    <div><b>دقت کن:</b> برای استفاده از قلب و خشاب باید به سوال معنی واژگان به درستی پاسخ دهی!</div>
                </div>
            </div>
            <button class="start-btn" style="background: linear-gradient(145deg, #4CAF50, #2E7D32); box-shadow: 0 6px 0 #1B5E20; color: #fff;" onclick="startGame()">فهمیدم، بزن بریم!</button>
        </div>
    </div>

    <!-- مدال انتخاب پس از مرحله ۱۰ -->
    <div id="level10Modal">
        <div class="modal-content">
            <h2 style="color: #4CAF50; font-size: 26px;">🎉 قهرمان شدی!</h2>
            <p style="font-size: 16px; margin-bottom: 25px; font-weight: bold; line-height: 1.8; color: #555;">
                تبریک! ۱۰ مرحله اصلی رو با موفقیت به پایان رسوندی و تمام پایگاه‌ها رو نابود کردی.<br>
                حالا دوست داری چیکار کنی؟
            </p>
            <button class="start-btn continue-btn" onclick="continueEndless()">می‌خوام ادامه بدم (رکوردزنی) 🚀</button>
            <button class="start-btn" style="background: linear-gradient(145deg, #FFD740, #FFC400); box-shadow: 0 6px 0 #FF8F00; color: var(--dark);" onclick="showFinalReport()">نمایش کارنامه 🏆</button>
        </div>
    </div>

    <div id="questionModal">
        <div class="modal-content">
            <h2 id="questionText">معنی این کلمه چیست؟</h2>
            <div class="options-grid" id="optionsContainer"></div>
        </div>
    </div>

    <div id="countdownModal">
        <div>
            <div id="encouragementText" class="encouragement" style="display:none;"></div>
            <span id="countdownText">3</span>
            <div id="continueText">ادامه...</div>
        </div>
    </div>

    <div id="messageModal">
        <div class="modal-content">
            <h2 id="msgBoxText" style="color: #4CAF50; font-size: 26px; line-height: 1.6;"></h2>
        </div>
    </div>

    <div id="gameOverModal">
        <div class="modal-content">
            <h2 id="gameOverTitle">💥 تصادف کردی! کارنامه بازی</h2>
            <div class="stats-grid">
                <div>👤 بازیکن: <span id="finalName"></span></div>
                <div>🏆 سطح: <span id="finalLevel"></span></div>
                <div>⭐ امتیاز: <span id="finalScore"></span></div>
                <div>⏱ زمان: <span id="finalTime"></span>s</div>
                <div>🛣 مسافت: <span id="finalDist"></span> km</div>
                <div>⚡ بیشترین سرعت: <span id="finalSpeed"></span>%</div>
                <div style="grid-column: span 2; text-align: center;">✅ پاسخ صحیح: <span id="finalCorrect"></span></div>
            </div>
            <div class="motivation" id="gameoverMotiv">شکست مقدمه پیروزیه، دفعه بعد حتما رکورد می‌زنی قهرمان! 🌟</div>
            <button class="start-btn continue-btn no-print" id="btnRevive" onclick="revivePlayer()" style="display:none;">ادامه بده (آخرین فرصت)</button>
            <button class="start-btn no-print" onclick="window.print()" style="background: linear-gradient(145deg, #FFD740, #FFC400); box-shadow: 0 6px 0 #FF8F00; margin-bottom:10px;">چاپ کارنامه</button>
            <button class="start-btn no-print" onclick="location.reload()">دوباره بازی کن</button>
        </div>
    </div>

    <script>
        function showGuide() {
            let nameInput = document.getElementById('playerNameInput').value.trim();
            if(nameInput !== "") playerName = nameInput;
            document.getElementById('nameDisplay').innerText = playerName;
            
            document.getElementById('startModal').style.display = 'none';
            document.getElementById('guideModal').style.display = 'flex';
        }

        let bgMusic, shootSoundTemplate, tankAudio, reloadAudio, turboAudio, applauseAudio;
        let audioCtx;
        let isMuted = false;

        function initMediaFiles() {
            if (!bgMusic) {
                bgMusic = new Audio('https://s11.uupload.ir/files/notebooklm/Non%20Vocal%20Bass%20Music%20_04%20[SevilMusic]%20(1).mp3');
                bgMusic.loop = true; bgMusic.volume = 0.3;
                
                shootSoundTemplate = new Audio('https://sedatoseda.com/wp-content/uploads/shotgun-sound.mp3');
                shootSoundTemplate.volume = 0.8;
                
                tankAudio = new Audio('https://sedatoseda.com/wp-content/uploads/tank-moving-143104.mp3');
                tankAudio.loop = true; 
                tankAudio.volume = 0.6; 
                
                reloadAudio = new Audio('https://dl4.fara-download.ir/audio/sound_effect/objects/guns/reload/gun_reload3.mp3');
                reloadAudio.volume = 0.9;
                
                turboAudio = new Audio('https://sedatoseda.com/wp-content/uploads/Turbo-sound-2.mp3');
                turboAudio.volume = 0.8;
                
                applauseAudio = new Audio('https://sedatoseda.com/wp-content/uploads/Applause-Sound-2.mp3');
                applauseAudio.volume = 0.8;
            }

            if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
            if(audioCtx.state === 'suspended') audioCtx.resume();
        }

        function playSfx(type) {
            if (isMuted || !audioCtx) return;
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            gain.gain.value = 1.0;
            const now = audioCtx.currentTime;

            if (type === 'crash') {
                osc.type = 'sawtooth';
                osc.frequency.setValueAtTime(150, now);
                osc.frequency.exponentialRampToValueAtTime(10, now + 0.5);
                gain.gain.setValueAtTime(1.0, now);
                gain.gain.exponentialRampToValueAtTime(0.01, now + 0.5);
                osc.start(now); osc.stop(now + 0.5);
            } else if (type === 'powerup') {
                osc.type = 'sine';
                osc.frequency.setValueAtTime(400, now);
                osc.frequency.linearRampToValueAtTime(800, now + 0.3);
                gain.gain.setValueAtTime(1.0, now);
                gain.gain.exponentialRampToValueAtTime(0.01, now + 0.3);
                osc.start(now); osc.stop(now + 0.3);
            } else if (type === 'correct') {
                osc.type = 'square';
                osc.frequency.setValueAtTime(400, now);
                osc.frequency.setValueAtTime(600, now + 0.1);
                gain.gain.setValueAtTime(1.0, now);
                gain.gain.exponentialRampToValueAtTime(0.01, now + 0.3);
                osc.start(now); osc.stop(now + 0.3);
            } else if (type === 'wrong') {
                osc.type = 'sawtooth';
                osc.frequency.setValueAtTime(300, now);
                osc.frequency.linearRampToValueAtTime(100, now + 0.4);
                gain.gain.setValueAtTime(1.0, now);
                gain.gain.exponentialRampToValueAtTime(0.01, now + 0.4);
                osc.start(now); osc.stop(now + 0.4);
            } else if (type === 'enemyShoot') {
                osc.type = 'square';
                osc.frequency.setValueAtTime(800, now);
                osc.frequency.exponentialRampToValueAtTime(100, now + 0.2);
                gain.gain.setValueAtTime(0.5, now);
                gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2);
                osc.start(now); osc.stop(now + 0.2);
            }
        }

        function toggleMute() {
            isMuted = !isMuted;
            const btn = document.getElementById('muteBtn');
            if (isMuted) {
                if(bgMusic) bgMusic.pause(); 
                if(tankAudio) tankAudio.pause(); 
                if(turboAudio) turboAudio.pause(); 
                if(applauseAudio) applauseAudio.pause();
                btn.innerText = '🔇';
            } else {
                if(bgMusic) bgMusic.play().catch(e => console.log(e));
                btn.innerText = '🔊';
            }
        }

        const canvas = document.getElementById('gameCanvas');
        const ctx = canvas.getContext('2d');
        
        let width, height, roadWidth;
        let targetLanes = 3;
        let currentLanes = 3;
        let laneWidth;
        let curveDirection = 1;
        let targetCurveMagnitude = 0;
        let currentCurveMagnitude = 0;

        function resize() {
            width = window.innerWidth > 600 ? 600 : window.innerWidth;
            height = window.innerHeight;
            canvas.width = width;
            canvas.height = height;
            roadWidth = width - 30;
            laneWidth = roadWidth / currentLanes;
            player.y = height - 120; 
            player.currentX = 15 + (player.lane * laneWidth) + (laneWidth / 2);
        }
        window.addEventListener('resize', resize);

        function getCurveOffset(y) {
            let relativeY = height - y;
            if (relativeY < 0) relativeY = 0;
            let factor = Math.pow(relativeY / height, 1.5);
            return Math.sin(distance * 0.003 * curveDirection) * factor * (width * currentCurveMagnitude);
        }
        
        let gameLoopId;
        let isPaused = false;
        let frames = 0;
        let score = 0, lives = 5, ammo = 5, distance = 0, time = 0, level = 1; 
        let correctAnswers = 0;
        let playerName = "بازیکن";
        let roadOffset = 0;
        let initialGameSpeed = 5;
        let gameSpeed = initialGameSpeed;
        let maxSpeedReached = 100;
        let difficultyMultiplier = 1;
        let activePowerup = null;
        let hasRevived = false;
        let MAX_LEVEL = 10;
        let isEndlessMode = false;
        
        let lastTurboTime = 0;
        let lastRepairTime = 0;
        let lastAmmoTime = 0;
        let lastShieldTime = 0;

        let isBossMode = false;
        let boss = null;
        let bossBullets = [];
        let bossBasesDestroyed = 0;
        let preBossGameSpeed = 5;

        function getEncouragement() {
            const list = [
                `آفرین قهرمان ${playerName}! 🥇`, 
                `کارت عالی بود ${playerName}! 🌟`, 
                `تو بی‌نظیری ${playerName}! 🚀`, 
                `ایول دانشمند کوچک! 💡`, 
                `فوق‌العاده‌ای ${playerName}! 🤩`
            ];
            return list[Math.floor(Math.random() * list.length)];
        }

        const vocabList = [
            { w: "سلیمان", m: "نام یکی از پیامبران الهی" }, { w: "مهارت", m: "ماهر بودن در کاری" },
            { w: "موری", m: "مورچه ای" }, { w: "حساب کردن", m: "شمردن" },
            { w: "وزان", m: "مخفف و از آن" }, { w: "اختر شناسی", m: "ستاره شناسی ، نجوم" },
            { w: "گران", m: "بزرگ و سنگین" }, { w: "حکمت", m: "دانش و معرفت و علم" },
            { w: "کاه", m: "علف" }, { w: "ناگزیر", m: "ناچار" },
            { w: "سعی", m: "تلاش و کوشش" }, { w: "نان آور خانه", m: "کسی که مایحتاج خانواده را فراهم می‌‌کند" },
            { w: "فارغ", m: "آسوده ، راحت" }, { w: "یاور", m: "یاری کننده" },
            { w: "به تندی", m: "به سرعت" }, { w: "کسب علم و معرفت", m: "به دست آوردن علم و دانش" },
            { w: "مسکین", m: "نیازمند" }, { w: "مهرگان", m: "پاییز ، اوایل پاییز" },
            { w: "ملک", m: "سرزمین، قلمرو" }, { w: "دانستم", m: "فهمیدم، دریافتم" },
            { w: "خونابه خوردن", m: "رنج بسیار کشیدن" }, { w: "عزم", m: "قصد ، اراده" },
            { w: "میازار", m: "آزار نرسان" }, { w: "شدم", m: "رفتم" },
            { w: "سور", m: "جشن و مهمانی" }, { w: "عالمان", m: "دانایان، خردمندان" },
            { w: "قناعت", m: "قانع بودن" }, { w: "مردم عادی", m: "عامه ی مردم" },
            { w: "توشه", m: "خوراک و آذوقه سفر" }, { w: "دیار", m: "سرزمین ، ناحیه" },
            { w: "گنج", m: "گوهر ها و چیزهای قیمتی" }, { w: "پژوهش", m: "تحقیق" },
            { w: "همواره", m: "همیشه" }, { w: "خردمندانه", m: "عاقلانه" },
            { w: "کامکاری", m: "نیک بختی ، خوش بختی" }, { w: "چه بسا", m: "بسیار ، فراوان" },
            { w: "رسم", m: "روش ، شیوه" }, { w: "پرسشگر", m: "سوال کننده" },
            { w: "بردباری", m: "شکیبایی، صبر" }, { w: "هوشمندی", m: "آگاهی" },
            { w: "هشیاران", m: "عاقلان، دانایان" }, { w: "گَه", m: "مخفف گاه" },
            { w: "به سبب", m: "به علت" }, { w: "تدبیر", m: "اندیشیدن به منظور پیدا کردن راه حلی برای مشکل" },
            { w: "پس از درگذشت مادر", m: "پس از فوت مادر" }, { w: "عاقل", m: "دانا ، عالم" },
            { w: "راهزنی", m: "غارتگری" }, { w: "بینا", m: "آگاه و هوشیار" },
            { w: "سکه", m: "پول فلزی" }, { w: "پیرایه", m: "آنچه سبب زیبایی شود، ابزار آراستن، زیور و زینت" },
            { w: "صادق", m: "راستگو" }, { w: "اینک", m: "حالا" },
            { w: "دینار", m: "سکه ی طلا" }, { w: "پیشگاه", m: "صحن" },
            { w: "حضور یافته ام", m: "مشرف شده ام، آمده ام" }, { w: "ناپسند", m: "نکوهیده، زشت" },
            { w: "جایگاه", m: "مرتبه ، درجه" }, { w: "صمیمی", m: "بسیار نزدیک" },
            { w: "رحمت حق بر آنان باد", m: "لطف خدا بر آنان باد" }, { w: "هم نشین", m: "دوست" },
            { w: "شوق آموختن", m: "علاقه به یاد گرفتن" }, { w: "خاکیان", m: "اهل خاک، مردم و انسان ها" },
            { w: "مکتب", m: "مدرسه ، دبستان" }, { w: "برکرده اند", m: "بلند کرده‌اند" },
            { w: "از بر کردم", m: "حفظ کردم" }, { w: "خاکدان", m: "دنیای خاکی، این جهان" },
            { w: "آداب", m: "رسم و روش" }, { w: "ضمیر", m: "باطن" },
            { w: "معین کرد", m: "مشخص کرد" }, { w: "لطف", m: "مهربانی ، رحمت" },
            { w: "پر مهر", m: "پر از عشق و محبت" }, { w: "پرتو", m: "روشنایی" },
            { w: "اثر گذار", m: "تاثیر گذار" }, { w: "معرفت", m: "شناخت و علم" },
            { w: "ماندگار", m: "پایدار، ماندنی" }, { w: "بپرور", m: "پرورش بده" },
            { w: "بدگویی حسودان", m: "بد گفتن و به زشتی یاد کردن انسان‌های حسود" }, { w: "نیک", m: "خوش، خوب" },
            { w: "رانده شده", m: "اخراج شد" }, { w: "خوارزم", m: "نام سرزمینی که ابوریحان در آن زندگی می‌‌کرد" },
            { w: "غافلان", m: "نادانان" }
        ];

        let availableVocabList = [...vocabList];

        function drawCar(ctx, x, y, baseColor, isPlayer = false, isEnemy = false) {
            ctx.save();
            ctx.translate(x, y);
            if (isEnemy) ctx.rotate(Math.PI); 
            ctx.scale(0.6, 0.6); 
            
            ctx.fillStyle = "rgba(0, 0, 0, 0.6)";
            ctx.beginPath();
            ctx.roundRect(-24, -38, 48, 80, 12);
            ctx.fill();

            ctx.fillStyle = "#111";
            ctx.fillRect(-26, -26, 10, 18);
            ctx.fillRect(16, -26, 10, 18);
            ctx.fillRect(-26, 14, 10, 18);
            ctx.fillRect(16, 14, 10, 18);
            
            let carGrad = ctx.createLinearGradient(-20, 0, 20, 0);
            if(baseColor === "#D50000") {
                carGrad.addColorStop(0, "#8E0000");
                carGrad.addColorStop(0.5, "#FF1744");
                carGrad.addColorStop(1, "#8E0000");
            } else {
                carGrad.addColorStop(0, "#01579B");
                carGrad.addColorStop(0.5, "#29B6F6");
                carGrad.addColorStop(1, "#01579B");
            }

            ctx.fillStyle = carGrad;
            ctx.beginPath();
            ctx.roundRect(-20, -36, 40, 72, 12);
            ctx.fill();
            
            if (isPlayer) {
                ctx.fillStyle = "#FFF";
                ctx.fillRect(-4, -34, 8, 68);
            }

            let glassGrad = ctx.createLinearGradient(0, -18, 0, 18);
            glassGrad.addColorStop(0, "#81D4FA");
            glassGrad.addColorStop(1, "#0277BD");
            ctx.fillStyle = glassGrad;
            ctx.beginPath();
            ctx.roundRect(-16, -20, 32, 40, 6);
            ctx.fill();
            
            ctx.fillStyle = carGrad;
            ctx.beginPath();
            ctx.roundRect(-14, -10, 28, 20, 4);
            ctx.fill();

            ctx.fillStyle = "#FFF59D";
            ctx.shadowColor = "#FFF59D";
            ctx.shadowBlur = 15;
            ctx.beginPath();
            ctx.roundRect(-16, -35, 8, 5, 2);
            ctx.roundRect(8, -35, 8, 5, 2);
            ctx.fill();
            ctx.shadowBlur = 0; 
            
            ctx.fillStyle = "#FF1744";
            ctx.beginPath();
            ctx.roundRect(-16, 32, 8, 4, 1);
            ctx.roundRect(8, 32, 8, 4, 1);
            ctx.fill();
            ctx.restore();
        }

        function drawTank(ctx, x, y, hp, scale = 0.6) {
            ctx.save();
            ctx.translate(x, y);
            ctx.rotate(Math.PI); 
            ctx.scale(scale, scale);
            
            ctx.fillStyle = "rgba(0, 0, 0, 0.6)";
            ctx.fillRect(-40, -50, 80, 100);

            ctx.fillStyle = "#111";
            ctx.fillRect(-38, -52, 18, 104);
            ctx.fillRect(20, -52, 18, 104);
            ctx.fillStyle = "#555";
            for(let i = -50; i < 50; i += 10) {
                ctx.fillRect(-38, i, 18, 4);
                ctx.fillRect(20, i, 18, 4);
            }
            
            let tankGrad = ctx.createLinearGradient(-25, 0, 25, 0);
            tankGrad.addColorStop(0, "#2E3B32");
            tankGrad.addColorStop(0.5, "#4CAF50");
            tankGrad.addColorStop(1, "#2E3B32");
            ctx.fillStyle = tankGrad; 
            ctx.beginPath();
            ctx.roundRect(-25, -45, 50, 90, 8);
            ctx.fill();

            let barrelGrad = ctx.createLinearGradient(-8, 0, 8, 0);
            barrelGrad.addColorStop(0, "#1B5E20");
            barrelGrad.addColorStop(1, "#0A210C");
            ctx.fillStyle = barrelGrad;
            ctx.fillRect(-8, -75, 16, 50);
            ctx.fillStyle = "#000";
            ctx.fillRect(-10, -80, 20, 6);

            ctx.fillStyle = tankGrad;
            ctx.shadowColor = "rgba(0,0,0,0.6)";
            ctx.shadowOffsetY = 5;
            ctx.shadowBlur = 10;
            ctx.beginPath();
            ctx.arc(0, 5, 25, 0, Math.PI * 2);
            ctx.fill();
            ctx.shadowBlur = 0;
            ctx.shadowOffsetY = 0;

            if(hp <= 5 && scale > 1) {
                ctx.fillStyle = "rgba(255, 60, 0, 0.5)";
                ctx.beginPath();
                ctx.arc(0, 5, 25, 0, Math.PI * 2);
                ctx.fill();
            }
            ctx.restore();
        }

        function drawPowerupIcon(ctx, x, y, type) {
            ctx.save();
            ctx.translate(x, y);
            ctx.scale(0.75, 0.75); 
            ctx.beginPath();
            ctx.arc(0, 0, 22, 0, Math.PI*2);
            
            if(type === 'repair') {
                ctx.fillStyle = "rgba(255, 20, 147, 0.3)";
                ctx.shadowColor = "#FF1493";
                ctx.shadowBlur = 15;
                ctx.fill();
                ctx.shadowBlur = 0;
                ctx.fillStyle = "#FF1493";
                ctx.beginPath();
                ctx.moveTo(0, 8);
                ctx.bezierCurveTo(-10, -2, -20, -8, -10, -15);
                ctx.bezierCurveTo(-2, -20, 0, -10, 0, -10);
                ctx.bezierCurveTo(0, -10, 2, -20, 10, -15);
                ctx.bezierCurveTo(20, -8, 10, -2, 0, 8);
                ctx.fill();
            } 
            else if(type === 'ammo') {
                ctx.fillStyle = "rgba(0, 229, 255, 0.3)";
                ctx.shadowColor = "#00E5FF";
                ctx.shadowBlur = 15;
                ctx.fill();
                ctx.shadowBlur = 0;
                ctx.fillStyle = "#00E5FF";
                ctx.beginPath();
                ctx.roundRect(-6, -10, 12, 18, 2);
                ctx.fill();
                ctx.fillStyle = "#00B0FF";
                ctx.beginPath();
                ctx.moveTo(-6, -10);
                ctx.lineTo(0, -16);
                ctx.lineTo(6, -10);
                ctx.fill();
            }
            else if(type === 'turbo') {
                ctx.fillStyle = "rgba(255, 234, 0, 0.3)";
                ctx.shadowColor = "#FFEA00";
                ctx.shadowBlur = 15;
                ctx.fill();
                ctx.shadowBlur = 0;
                ctx.fillStyle = "#FFEA00";
                ctx.beginPath();
                ctx.moveTo(4, -14);
                ctx.lineTo(-10, 2);
                ctx.lineTo(0, 2);
                ctx.lineTo(-4, 14);
                ctx.lineTo(10, -2);
                ctx.lineTo(0, -2);
                ctx.closePath();
                ctx.fill();
            }
            else if(type === 'shield') {
                ctx.fillStyle = "rgba(255, 193, 7, 0.3)";
                ctx.shadowColor = "#FFC107";
                ctx.shadowBlur = 15;
                ctx.fill();
                ctx.shadowBlur = 0;
                ctx.fillStyle = "#FFC107";
                ctx.beginPath();
                ctx.moveTo(0, -15);
                ctx.lineTo(12, -8);
                ctx.lineTo(12, 5);
                ctx.lineTo(0, 15);
                ctx.lineTo(-12, 5);
                ctx.lineTo(-12, -8);
                ctx.closePath();
                ctx.fill();
                ctx.fillStyle = "#FF8F00";
                ctx.beginPath();
                ctx.moveTo(0, -10);
                ctx.lineTo(8, -5);
                ctx.lineTo(8, 3);
                ctx.lineTo(0, 10);
                ctx.lineTo(-8, 3);
                ctx.lineTo(-8, -5);
                ctx.closePath();
                ctx.fill();
            }
            ctx.restore();
        }

        const player = {
            lane: 1, 
            currentX: 0,
            y: 0, 
            turboTimer: 0,
            shieldTimer: 0,
            draw() {
                let targetX = 15 + (this.lane * laneWidth) + (laneWidth / 2);
                this.currentX += (targetX - this.currentX) * 0.2;
                let finalX = this.currentX + getCurveOffset(this.y);

                drawCar(ctx, finalX, this.y, "#D50000", true); 

                if(this.turboTimer > 0) {
                    ctx.fillStyle = "#00E5FF";
                    ctx.shadowColor = "#00E5FF";
                    ctx.shadowBlur = 15;
                    ctx.beginPath();
                    ctx.arc(finalX - 8, this.y + 30, 4 + Math.random()*3, 0, Math.PI*2);
                    ctx.arc(finalX + 8, this.y + 30, 4 + Math.random()*3, 0, Math.PI*2);
                    ctx.fill();
                    ctx.shadowBlur = 0;
                }
ادامه کد در پارت دوم ارسال می‌گردد